
#include <cassert>
#include <iostream>

#include <algorithm>
#include <vector>
using namespace std;

int main() {
  vector<int> vec(100);
  //   resize 也进行了初始化
  vec.resize(2);
  cout << vec[0] << "  " << vec[1] << endl;
  cout << vec.size() << "  " << vec.capacity() << endl;

  vec.resize(100);
  for (int i = 0; i < 100; ++i) {
    vec[i] = i % 10;
  }
  cout << "  \n\n";
  sort(vec.begin(), vec.end());
  auto p = unique(vec.begin(), vec.end());
  // vec.erase(p, vec.end());

  for (auto i = vec.begin(); i != p; ++i) {
    cout << *i << endl;
  }

  cout << "helllp\n";
  // remove duplicate elements
  std::vector<int> v{1, 2, 3, 1, 2, 3, 3, 4, 5, 4, 5, 6, 7};
  std::sort(v.begin(), v.end()); // 1 1 2 2 3 3 3 4 4 5 5 6 7
  auto last = std::unique(v.begin(), v.end());
  cout << "distance = " << distance(v.begin(), last) << endl;
  // v now holds {1 2 3 4 5 6 7 x x x x x x}, where 'x' is indeterminate
  v.erase(last, v.end());
  cout << "size = " << v.size() << endl;
  for (int i : v)
    std::cout << i << " ";
  std::cout << "\n";

  vector<bool> vb(10240);
  cout << sizeof(vb) << endl;

  cout << -1 + true << endl;
  cout << -1 + false << endl;

  int vei[]{1, 2, 3, 1, 2, 3, 3, 4, 5, 4, 5, 6, 7};
  sort(vei, vei + 13);
  auto lia = unique(vei, vei + 13);

  for (auto iter = vei; iter != lia; ++iter)
    cout << *iter << endl;

  cout << (&vei[12] - vei) << endl;

  return 0;
}